package cn.wygandwdn.core.serializer;

import cn.wygandwdn.common.enumeration.SerializerType;
import cn.wygandwdn.core.serializer.gson.GsonSerializer;
import cn.wygandwdn.core.serializer.proto.ProtoSerializer;
import cn.wygandwdn.core.serializer.WtSerializer;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @description:    获取对应的序列化器工具类
 * @author: WYG
 * @time: 2021/10/24 19:51
 */

public class SerializerUtil {
    private static final Map<Integer, WtSerializer> serializerMap = Maps.newHashMap();

    static {
        serializerMap.put(SerializerType.Proto.getCode(), new ProtoSerializer());
        serializerMap.put(SerializerType.Gson.getCode(), new GsonSerializer());
        serializerMap.put(SerializerType.Kryo.getCode(), new GsonSerializer());
    }

    public static WtSerializer getSerializer(Integer serializeType) {
        return serializerMap.get(serializeType);
    }
}
